16 #ifdef __MSP430_HAS_USCI_Ax__
21 bool USCI_A_SPI_initMaster(uint16_t baseAddress, USCI_A_SPI_initMasterParam *
param)
24 HWREG8(baseAddress + OFS_UCAxCTL1) |= UCSWRST;
27 HWREG8(baseAddress + OFS_UCAxCTL0) &= ~(UCCKPH + UCCKPL + UC7BIT + UCMSB +
28 UCMST + UCMODE_3 + UCSYNC);
31 HWREG8(baseAddress + OFS_UCAxCTL1) &= ~(UCSSEL_3);
34 HWREG8(baseAddress + OFS_UCAxCTL1) |=
param->selectClockSource;
36 HWREG16(baseAddress + OFS_UCAxBRW) =
37 (uint16_t)(
param->clockSourceFrequency /
param->desiredSpiClock);
46 HWREG8(baseAddress + OFS_UCAxCTL0) |= (
49 param->clockPolarity +
55 HWREG8(baseAddress + OFS_UCAxMCTL) = 0;
60 void USCI_A_SPI_changeMasterClock(uint16_t baseAddress,
61 USCI_A_SPI_changeMasterClockParam *
param)
64 HWREG8(baseAddress + OFS_UCAxCTL1) |= UCSWRST;
66 HWREG8(baseAddress + OFS_UCAxBRW) =
67 (uint16_t)(
param->clockSourceFrequency /
param->desiredSpiClock);
70 HWREG8(baseAddress + OFS_UCAxCTL1) &= ~(UCSWRST);
72 bool USCI_A_SPI_initSlave (uint16_t baseAddress,
80 HWREG8(baseAddress + OFS_UCAxCTL1) |= UCSWRST;
83 HWREG8(baseAddress + OFS_UCAxCTL0) &= ~(UCMSB +
92 HWREG8(baseAddress + OFS_UCAxCTL0) |= (clockPhase +
102 void USCI_A_SPI_changeClockPhasePolarity (uint16_t baseAddress,
104 uint8_t clockPolarity
109 HWREG8(baseAddress + OFS_UCAxCTL1) |= UCSWRST;
111 HWREG8(baseAddress + OFS_UCAxCTL0) &= ~(UCCKPH + UCCKPL);
113 HWREG8(baseAddress + OFS_UCAxCTL0) |= (
119 HWREG8(baseAddress + OFS_UCAxCTL1) &= ~(UCSWRST);
122 void USCI_A_SPI_transmitData ( uint16_t baseAddress,
129 uint8_t USCI_A_SPI_receiveData (uint16_t baseAddress)
131 return (
HWREG8(baseAddress + OFS_UCAxRXBUF)) ;
134 void USCI_A_SPI_enableInterrupt (uint16_t baseAddress,
138 HWREG8(baseAddress + OFS_UCAxIE) |= mask;
141 void USCI_A_SPI_disableInterrupt (uint16_t baseAddress,
145 HWREG8(baseAddress + OFS_UCAxIE) &= ~mask;
148 uint8_t USCI_A_SPI_getInterruptStatus (uint16_t baseAddress,
152 return (
HWREG8(baseAddress + OFS_UCAxIFG) & mask );
155 void USCI_A_SPI_clearInterrupt (uint16_t baseAddress,
159 HWREG8(baseAddress + OFS_UCAxIFG) &= ~mask;
162 void USCI_A_SPI_enable (uint16_t baseAddress)
165 HWREG8(baseAddress + OFS_UCAxCTL1) &= ~(UCSWRST);
168 void USCI_A_SPI_disable (uint16_t baseAddress)
171 HWREG8(baseAddress + OFS_UCAxCTL1) |= UCSWRST;
174 uint32_t USCI_A_SPI_getReceiveBufferAddressForDMA (uint16_t baseAddress)
176 return ( baseAddress + OFS_UCAxRXBUF );
179 uint32_t USCI_A_SPI_getTransmitBufferAddressForDMA (uint16_t baseAddress)
181 return ( baseAddress + OFS_UCAxTXBUF );
184 uint8_t USCI_A_SPI_isBusy (uint16_t baseAddress)
187 return (
HWREG8(baseAddress + OFS_UCAxSTAT) & UCBUSY);
MPU_initThreeSegmentsParam param